Agenda
- Introduction to time series analysis and forecasting
- Time series objects - introduction to the time series classes and their attributes
- Descriptive analysis of time series
- Linear regression-based forecasting models
- The ARIMA family of models
Assumptions
- Some background in R
- Basic knowledge in probability
- Familiar with linear regression
Why R?
- Statistical programming language
- A vast amount of packages for time series analysis
- The forecast package (and soon the fable package)
Goals
By the end of this workshop, you probably won’t become an expert in time series analysis and forecasting, but you will be able to:
- Explore time series data with some basic tools
- Use discriptive statistics for identifying seasonal and correlation patterns
- Build basic forecasting model
Admin
Workshop material
All today’s slides, code, and rmarkdown files are available on GitHub
Downloading the workshop material from the terminal:
git clone https://github.com/RamiKrispin/Time-Series-Workshop.git
Or lunch it from a docker container:
Introduction to time series analysis
Time series analysis is commonly used in many fields of science, such as economics, finance, physics, engineering, and astronomy. The usage of time series analysis to understand past events and to predict future ones did not start with the introduction of the stochastic process during the past century. Ancient civilizations such as the Greeks, Romans, or Mayans, researched and learned how to utilize cycled events such as weather and astronomy to predict future events.
Time series analysis - is the art of extracting meaningful insights from time-series data to learn about past events and to predict future events.
This process includes the following steps:
- Data collection - pulling the raw data from a database, API, flat files etc.
- Data prep - cleaning, reformating (dates, classes, etc.), aggregating
- Descriptive analysis - using statistical methods and data visualization tools to extract insights and learn about the series components and patterns
- Predictive analysis - leveraging the insights learned in the descriptive process and apply some predictive model
Generally, in R this process will look like this:

Of course, there are more great packages that could be part of this process such as zoo, xts, bsts, forecastHybird, TSstudio, etc.
Time series data
Time series data - is a sequence of values, each associate to a unique point in time that can divide to the following two groups:
- Regular time series - is a sequence of observations which were captured at equally spaced time intervals (e.g., every month, week, day, hour, etc.)
- Irregular time series - or unevenly spaced time series, is a sequence of observations which were not captured on equally spaced time intervals (for example rainy days, earthquakes, clinical trials, etc.)
Note: typically, the term time series data referred to regular time-series data. Therefore, if not stated otherwise, throughout the workshop the term time series (or series) refer to regular time-series data
Examples of time series data
Applications
With time series analysis, you can answer questions such as:
- How many vehicles, approximately, going to be sold in the US in the next 12 months?
- What will be the estimated demand for natural gas in the US in the next five years?
- Generally, what will be the demand for electricity in the UK during the next 24 hours?